package com.dragon.backstage.domain.param.user;

import com.dragon.common.domain.param.PaginationParam;
import com.dragon.common.utils.AjaxResult;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.NoArgsConstructor;
import lombok.experimental.SuperBuilder;

import java.util.Objects;

/**
 * 用户模块-授权角色列表请求参数
 *
 * @author dragon
 * @version 1.0
 * @date 2024/8/8 18:23
 */
@Data
@SuperBuilder
@NoArgsConstructor
@AllArgsConstructor
@EqualsAndHashCode(callSuper = true)
@Schema(title = "用户模块-授权角色列表请求参数")
public class UserAuthRoleParam extends PaginationParam {

    /**
     * 用户ID
     */
    @Schema(title = "用户ID", requiredMode = Schema.RequiredMode.REQUIRED)
    private Long userId;


    /**
     * 参数校验
     */
    public static AjaxResult<Void> check(UserAuthRoleParam param) {
        if (Objects.isNull(param)) {
            return AjaxResult.failed("请求参数不能为空");
        }
        if (Objects.isNull(param.getUserId()) || param.getUserId() < 1) {
            return AjaxResult.failed("用户ID不能为空");
        }

        return AjaxResult.succeed();
    }

}
